package com.xyoto.community.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * Author: 廖振辉
 * Date: 2022/1/15
 * Description:
 */
public class UrlTranslationUtil {

    /**
     * 将微信文章链接进行转码
     * @author 廖振辉
     * @param url 微信文章链接
     * @return {@link String} 编码后的微信文章链接
     */
    private static String encodeWechatLink(String url){
        String decode = null;
        try {
            decode = URLEncoder.encode(url,"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return decode;
    }

    /**
     * 获取完整的编码后的微信文章链接
     * @author 廖振辉
     * @param url 微信文章链接
     * @return {@link String}
     */
    public static String getWechatArticleLink(String url){
        return "/pages/WebView/index?url=" + encodeWechatLink(url);
    }
}
